Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GTIN] Migration notice #2656

Merged
merged 19 commits into from
Nov 8, 2024

Conversation

puntope
Copy link
Contributor

@puntope puntope commented Oct 30, 2024

Changes proposed in this Pull Request:

Closes part of #2616 as part of pcTzPl-2p2-p2.

Related to #2655

Screenshots:

Screen.Recording.2024-10-29.at.20.44.24.mov
Screenshot 2024-10-29 at 20 48 00

Detailed test instructions:

  1. Set this in console to view the events localStorage.setItem( 'debug', 'wc-admin:*' )
  2. Enter into Google for WooCommerce (any page)
  3. See the banner
  4. Click on "click here." and the event wcadmin_gla_gtin_migration_banner_click
  5. See the modal opening and event wcadmin_gla_modal_open
  6. Close the modal and see event wcadmin_gla_modal_closed
  7. Repeat step 4
  8. Click on "Start Migration" in the modal and event wcadmin_gla_gtin_migration_banner_migration_start
  9. See the message "GTIN Migration was successfully scheduled" and event wcadmin_gla_gtin_migration_banner_migration_scheduled
  10. Verify the job gla/jobs/migrate_gtin/create_batch is scheduled. Dont run it
  11. Delete the option
  12. Repeat steps 7-8
  13. See the message "Unable to start GTIN Migration" and event wcadmin_gla_gtin_migration_banner_migration_failed

Additional details:

Changelog entry

Add - Banner for GTIN MIgration

@github-actions github-actions bot added type: enhancement The issue is a request for an enhancement. changelog: add A new feature, function, or functionality was added. labels Oct 30, 2024
@puntope puntope marked this pull request as ready for review October 30, 2024 02:55
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 43.47826% with 52 lines in your changes missing coverage. Please review.

Project coverage is 64.7%. Comparing base (160892b) to head (3c2e950).
Report is 20 commits behind head on add/gtin-migration-api-controller.

Files with missing lines Patch % Lines
...nts/gtin-migration-banner/gtin-migration-banner.js 34.3% 23 Missing ⚠️
src/HelperTraits/GTINMigrationUtilities.php 53.3% 7 Missing ⚠️
...c/API/Site/Controllers/GTINMigrationController.php 57.1% 6 Missing ⚠️
js/src/data/resolvers.js 0.0% 5 Missing ⚠️
js/src/data/reducer.js 0.0% 3 Missing ⚠️
src/Jobs/MigrateGTIN.php 0.0% 3 Missing ⚠️
js/src/data/actions.js 0.0% 2 Missing ⚠️
js/src/hooks/useGTINMigrationStatus.js 77.8% 2 Missing ⚠️
src/ConnectionTest.php 0.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                          Coverage Diff                          @@
##             add/gtin-migration-api-controller   #2656     +/-   ##
=====================================================================
- Coverage                                 65.3%   64.7%   -0.6%     
- Complexity                                4628    4638     +10     
=====================================================================
  Files                                      476     798    +322     
  Lines                                    19379   24536   +5157     
  Branches                                     0    1242   +1242     
=====================================================================
+ Hits                                     12661   15875   +3214     
- Misses                                    6718    8488   +1770     
- Partials                                     0     173    +173     
Flag Coverage Δ
js-unit-tests 62.4% <38.6%> (?)
php-unit-tests 65.3% <51.4%> (-<0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
js/src/components/main-tab-nav/main-tab-nav.js 90.0% <100.0%> (ø)
js/src/data/action-types.js 100.0% <ø> (ø)
js/src/data/selectors.js 48.5% <100.0%> (ø)
src/Admin/Product/Attributes/Input/GTINInput.php 91.7% <100.0%> (-1.2%) ⬇️
src/ConnectionTest.php 0.0% <0.0%> (ø)
js/src/data/actions.js 7.9% <0.0%> (ø)
js/src/hooks/useGTINMigrationStatus.js 77.8% <77.8%> (ø)
js/src/data/reducer.js 82.5% <0.0%> (ø)
src/Jobs/MigrateGTIN.php 0.0% <0.0%> (ø)
js/src/data/resolvers.js 7.2% <0.0%> (ø)
... and 3 more

... and 313 files with indirect coverage changes

@puntope puntope requested a review from a team October 30, 2024 02:58
@puntope puntope changed the title Add/gtin migration notice [GTIN] Migration notice Oct 30, 2024
Copy link
Contributor

@mikkamp mikkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, they are working as expected. I just left a comment about checking if GTIN is supported in core. Also as we discussed we might want to give some more feedback on when the task is completed.

The code looks good to me, but we might just want to get a quick lookover by someone a bit more familiar with react to confirm the handling of the modals is done correctly.

src/Admin/Admin.php Outdated Show resolved Hide resolved
@puntope
Copy link
Contributor Author

puntope commented Nov 1, 2024

Hi @mikkamp I added several tweaks.

Now we do show 2 banners depending on the status of the migration.

I also refactored some code to prevent duplication. So for that, I created a Utility class to use as a trait.

Can you take another look?

ps. Notice I bumped min version to hide the GTIN to 2.8.7

@puntope puntope requested a review from mikkamp November 1, 2024 02:21
@puntope puntope self-assigned this Nov 1, 2024
Copy link
Contributor

@mikkamp mikkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, although it seems that it's fully relying on a status that is set on the page (meaning I have to reload the page to transition the banner status).

For the banner to completely clear it's not such a problem to have it stay until the page is refreshed. But for the transition between banners it looks kind of odd. When I start the migration I'm shown the new banner:
image

But if I switch to any other tab like Product Feed, or even go to another react page in WooCommerce it reverts back to the first banner (until I hard refresh the page):
image

Can we get that status updated dynamically so it keeps the status current?

src/HelperTraits/GTINMigrationUtilities.php Show resolved Hide resolved
src/Jobs/MigrateGTIN.php Outdated Show resolved Hide resolved
@puntope
Copy link
Contributor Author

puntope commented Nov 5, 2024

Hey @mikkamp Thanks for the new review. I did some changes fixing the issue with the banner not changing between tabs. I did also rename the value of the constants.

This is ready for another round. Thanks

@puntope puntope requested a review from mikkamp November 5, 2024 22:31
Copy link
Contributor

@mikkamp mikkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, the banners are working correctly now since the status is fetched and kept up to date. I just left some minor comments.

One thing that I think should still be addressed is handling duplicate GTIN numbers. The action scheduler doesn't handle that too well, because since they are done in batches, if one product fails the whole batch fails. It tries to redo the tasks until it reaches the failure threshold.

image

Anyways I'll go ahead and approve this PR if you'd like to handle the fatal in a follow up PR.

@@ -89,6 +95,22 @@ protected function start_migration_callback(): callable {
};
}

/**
* Callback function for scheduling GTIN migration job.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a copy paste error, but this is not the right description. Also, would it make more sense to call the function get_migration_status_callback?

src/HelperTraits/GTINMigrationUtilities.php Show resolved Hide resolved
@puntope puntope merged commit 8b7c586 into add/gtin-migration-api-controller Nov 8, 2024
15 checks passed
@puntope puntope deleted the add/gtin-migration-notice branch November 8, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants